<template>
	<view class="padb30">
		<cu-custom bgColor="bg-gradual-blue" isBack="true">
			<block slot="content">流程管理系统·工序生产情况</block>
		</cu-custom>
		
		<scroll-view scroll-x class="bg-white nav pos-f">
			<view class="cu-item ripple" :class="TabCur==index?'text-orange cur':''" @tap="tab(index)" 
			v-for="item,index in label">
				{{item}}
			</view>
		</scroll-view>
		<scroll-view scroll-x class="bg-white nav" style="visibility: hidden;z-index: -99;">
			<view class="cu-item ripple" :class="TabCur==index?'text-orange cur':''" @tap="tab(index)" 
			v-for="item,index in label">
				{{item}}
			</view>
		</scroll-view>
		
		<view class="mart5">
			<view class="list-style-1">生产情况</view>
		</view>
		
		<view>
			<view class="bcf round5  marlr3 pad2 mart5" v-for="item,index in list" :key="index">
				<view class="flrc padtb2 bdbso" :data-id="item.streamOrder.id" @tap="$win.goto('/pages/stream/orderInfo/orderInfo',$event)">
					<view class=" tar padlr3 padtb1 round1" >
						<text class="bg-black padlr3 padtb1 round1">{{item.point.name}}</text>
					</view>
					<view class="flex1 fs16 tar padr3">{{item.streamOrder.sn}}</view>
					<text class="fa fa-angle-right"></text>
				</view>
				<view class="flex-r flex-start c11 padtb3">
					<view class="wh20-20 mart3 marr2">
						<image  @tap="viewPic($api.getAssetBaseUrl() + item.streamOrder.cover,[$api.getAssetBaseUrl() + item.streamOrder.cover])"  
						:src="$api.getAssetBaseUrl() + item.streamOrder.cover" class="wh20-20" mode="aspectFill"></image>
					</view>
					<view class="flex1 lh15 fs16 tar">
						<view class="flex1 c11 lh2 fs10">{{item.streamOrder.info}}</view>
						<view class="flex-r flex-end"><text class="fs10 flex2 tar">工作量：</text><text class="tar flex1">{{item.numTotal}}</text></view>
						<view class="flex-r flex-end"><text class="fs10 flex2 tar">剩余任务：</text><text class="tar flex1">{{item.numLeft}}</text></view>
					</view>
				</view>
				<view class="bdtso pad3 lh2">
					<view>订单创建时间：{{$com.str2time(item.createAt)}}</view>
					<view>计划完成时间：{{$com.str2time(item.targetAt)}}</view>
					<view>实际开工时间：{{$com.str2time(item.startAt)}}</view>
					<view>实际完成时间：{{$com.str2time(item.finishAt)}}</view>
					<!-- <view class="flrc pad1 bdtda"><text class="flex1 c12">计划开始：</text>{{$com.str2time(item.createAt)}}</view> -->
					<!-- <view class="flrc pad1 bdtda"><text class="flex1 c12">计划完成：</text>{{$com.str2time(item.targetAt)}}</view> -->
					<!-- <view class="flrc pad1 bdtda"><text class="flex1 c12">实际开始：</text>{{$com.str2time(item.startAt)}}</view> -->
					<!-- <view class="flrc pad1 bdtda bdbda"><text class="flex1 c12">实际完成：</text>{{$com.str2time(item.finishAt)}}</view> -->
					<view class="list-style-2 mart3">订单备注</view>
					{{item.streamOrder.tips}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import api from '../../../static/js/api.js'
	import com from '../../../static/js/com.js'
	// import win from '../../../static/js/win.js'
	import list from '../../../static/js/list.js'
	export default {

		data() {
			return {
				id:0,
				TabCur:0,
				list: [],
				label: ["昨天","今天","明天","后天"],
				start:"",
				end:"",
			}
		},
		methods: {
			tab(index){
				this.TabCur = index
				var data = new Date()
				data.setDate(data.getDate()-1 + index)
				let start = com.getDate(data)
				data.setDate(data.getDate()+1)
				let end = com.getDate(data)
				this.start = start
				this.end = end
				console.log(start)
				console.log(end)
				this.getData()
			},
			goto(e){
				console.log(e)
				// this.$win.goto('/pages/stream/orderInfo/orderInfo?id='+id)
			},
			getData(){
				let _this = this
				list.setUrl('/api/streamOrderPoints')
				list.setData({
					_where:{
						eq:{'point.id':this.id},
						gt:{targetAt:this.start},
						lt:{targetAt:this.end}
					}
				})
				list.setCbFunc((res) => {
					console.log(res)
					this.list = res
				})
				list.reload()
			}
		},
		created() {
				
			// console.log(this.$route.query)
			
		},
		onLoad(option) {
				console.log(option)
				this.id = option.id
				let index = 1
				this.TabCur = 1
				var data = new Date()
				data.setDate(data.getDate()-1 + index)
				let start = com.getDate(data)
				data.setDate(data.getDate()+1)
				let end = com.getDate(data)
				this.start = start
				this.end = end
			this.getData()
		},
		onShow() {

		},
		onReachBottom() {
			list.getList()
		},
		onPullDownRefresh() {
			list.reload()
		}
	}
</script>

<style>

</style>
